package com.minelx.sequence.pattern.config;

import java.util.Collection;
import java.util.List;

public class JoiningReducer implements IReducer<String> {
	@Override
	public String reduce(List<?> elements) {
		return elements.stream()
				.map(element -> ((List<?>) element))
				.flatMap(Collection::stream)
				.map(Object::toString)
				.reduce((left, right) -> left + right).orElseThrow(RuntimeException::new);
	}
}
